package com.orangelife.mobile.zoning.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.curry.orangelife.mobile.R;
import com.curry.android.adapter.FatherAdapter;

import java.util.List;
import java.util.Map;
@SuppressWarnings("unchecked")
@Deprecated
public class SelectCommunityListViewAdapter<T> extends FatherAdapter<T> {

	private Context mContext;
	private LayoutInflater listContainer;
	private List<Map<String, Object>> item_name = null;

	public final class ListItemView {
		public TextView tv_item_name;
		public TextView tv_distance;
	}

	public SelectCommunityListViewAdapter(Context context,
			List<Map<String, Object>> item_name) {
		this.mContext = context;
		listContainer = LayoutInflater.from(mContext);
		this.item_name = item_name;
	}

	@Override
	public int getCount() {
		return item_name.size();
	}

	@Override
	public Object getItem(int position) {
		return item_name.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ListItemView listItemView;

		if (convertView == null) {
			listItemView = new ListItemView();
			convertView = listContainer.inflate(
					R.layout.item_lv_select_community, null);

			listItemView.tv_item_name = (TextView) convertView
					.findViewById(R.id.tv_community_name);
			listItemView.tv_distance = (TextView) convertView
					.findViewById(R.id.tv_community_distance);

			convertView.setTag(listItemView);
		} else {
			listItemView = (ListItemView) convertView.getTag();
		}
			listItemView.tv_item_name.setText(String.valueOf(item_name.get(position)
					.get("comm")));
		/*listItemView.tv_distance.setText(item_name.get(position)
						.get("phone").toString()+"千米");*/
		return convertView;
	}


	@Override
	public BaseAdapter setList(List<T> list) {
		this.item_name=(List<Map<String, Object>>) list;
		return SelectCommunityListViewAdapter.this;
	}

}